package net.zui;

import java.awt.Color;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.RenderingHints;
import java.awt.RenderingHints.Key;
import java.util.HashMap;
import java.util.Map;

import net.zui.entity.ZBorder;
import net.zui.util.UComm;
import net.zui.util.UDraw;

/**
 * 本框架的所有默认设置
 * <br /><br />
 * <b>作者:</b>张天文 <br />
 * <b>日期:</b>2021年4月19日上午11:29:12<br />
 * @date
 */
public class Option {
	/** 默认标题 */
	public static final String title="ZUI 0.0.1 for ztw";
	
	/** 默认时间格式化字符串 */
	public static final String def_data_format="yyyy-MM-dd kk:mm:ss";
	
	/** 透明颜色,用于图像生成 */
	public static final Color baseBackColor=new Color(0, 0, 0, 0);
	
	/** Graphics抗锯齿选项, 开启文字和绘制的抗锯齿 */
	public static final Map<Key, Object> renderingHints=new HashMap<Key, Object>(){
		private static final long serialVersionUID = 1L;
	{
		put(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
		put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	}};
	
	/** 默认间隔, 用例如: 文字靠右对齐, 距右边有该数值的距离 */
	public static int padding = 3;
	
	/** 背景色,默认淡灰 */
	private static Color backColor=UDraw.web("F4F4F5");
	/** 前景色,默认深灰色 */
	private static Color color=UDraw.web("333");
	/** 字体颜色,默认深灰色 */
	private static Color fontColor=UDraw.web("333");
	/** 边框颜色 */
	private static Color borderColor=UDraw.web("ccc");
	/** 边框鼠标移入颜色 */
	private static Color mouseInColor=UDraw.web("409EFF");
	
	private static ZBorder border=new ZBorder(1, 8, UDraw.web("DCDFE6"), UDraw.web("B3D8FF"));
	private static Color disabledBackColor = UDraw.web("EEE");
	private static ZBorder disabledBorder = new ZBorder(1, UDraw.web("eaeaea"));
	
	/** 默认字体 */
	private static Font font=getFont(14,"黑体","楷体","宋体","幼圆","微软雅黑","等线","仿宋","华文中宋",
			"华文楷体","新宋体", "Microsoft YaHei UI");
	public static Font getFont(int fontSize,String...fontNames) {
		GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
		Font[] fonts = environment.getAllFonts();
		for(Font font:fonts) {
			for(String s:fontNames) {
				if(UComm.equals(font.getFamily(), s)) {
					return new Font(s, 0, fontSize);
				}
			}
		}
		return new Font("黑体",0,fontSize);
	}
	
	public static void showFont() {
		GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
		Font[] fonts = environment.getAllFonts();
		for(Font font:fonts) {
			System.out.println(font.getName());
		}
	}
	
	public static Color getBackColor() {
		return backColor;
	}
	public static void setBackColor(Color backColor) {
		Option.backColor = backColor;
	}
	public static Color getColor() {
		return color;
	}
	public static void setColor(Color color) {
		Option.color = color;
	}
	public static Color getBorderColor() {
		return borderColor;
	}
	public static void setBorderColor(Color borderColor) {
		Option.borderColor = borderColor;
	}
	public static Color getMouseInColor() {
		return mouseInColor;
	}
	public static void setMouseInColor(Color mouseInColor) {
		Option.mouseInColor = mouseInColor;
	}
	public static Font getFont() {
		return font;
	}
	public static void setFont(Font font) {
		Option.font = font;
	}

	public static Color getFontColor() {
		return fontColor;
	}

	public static void setFontColor(Color fontColor) {
		Option.fontColor = fontColor;
	}

	public static Color getDisabledBackColor() {
		return disabledBackColor;
	}

	public static void setDisabledBackColor(Color disabledBackColor) {
		Option.disabledBackColor = disabledBackColor;
	}

	public static ZBorder getDisabledBorder() {
		return disabledBorder;
	}

	public static void setDisabledBorder(ZBorder disabledBorder) {
		Option.disabledBorder = disabledBorder;
	}

	public static ZBorder getBorder() {
		return border;
	}

	public static void setBorder(ZBorder border) {
		Option.border = border;
	}
}
